﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Prism.Games.GalEngine.Scripts.Data.SceneElements;

namespace Prism.Games.GalEngine.Scripts.Parser
{
    public class DialogueParser : ISceneParser
    {
        public DialogueParser()
        {
            this.HyperTextBlock = Helper.GraphicBase.FindName(Helper.GraphicBase.GalUIFrame.GamingFrame, "Dialogue") as GameFrameLibrary.HyperTextBlock;
            this.TextBlock = Helper.GraphicBase.FindName(Helper.GraphicBase.GalUIFrame.GamingFrame, "RoleName") as System.Windows.Controls.TextBlock;
        }

        public void Restart()
        {
            this.HyperTextBlock.HyperText = "";
        }

        public void PresentObject(FunctionModel.SceneObject element)
        {
            if (element is Dialogue)
            {
                var target = element as Dialogue;
                if (target.Text != null)
                {
                    this.HyperTextBlock.HyperText = target.Text;
                }
            }
        }

        public void PresentObject(FunctionModel.SceneObject element, Data.Role role)
        {
            if (role != null)
            {
                if (role.Name != null)
                {
                    this.TextBlock.Text = role.Name;
                }
                else { this.TextBlock.Text = ""; }
            }
            else { this.TextBlock.Text = ""; }

            this.PresentObject(element);
        }

        public GameFrameLibrary.HyperTextBlock HyperTextBlock { get; private set; }

        public System.Windows.Controls.TextBlock TextBlock { get; private set; }
    }
}
